<template>
    <div class="body">
    <div class="header">
    </div>
    <!-- title -->
    <img
      src="../../assets/img/disney/title@2x.png"
      class="images"
      alt=""
    >
    <!-- g购物卡 -->
    <div class="six">
      <ul>
        <li @click="nav({goods_id:7704})">
          <div class="btn">立即购买</div>
        </li>
        <li @click="nav({goods_id:7708})">
          <div class="btn">立即购买</div>
        </li>
        <li @click="nav({goods_id:7711})">
          <div class="btn">立即购买</div>
        </li>
        <li @click="nav({goods_id:7714})">
          <div class="btn">立即购买</div>
        </li>
      </ul>
    </div>
    <!-- title -->
    <img
      src="../../assets/img/disney/title1@2x.png"
      class="images"
      alt=""
    >
    <!-- 快乐 -->
    <div class="goods">
      <ul>
        <li
          v-for="item in list"
          :key="item.goods_id"
          @click="nav(item)"
        >
          <img
            :src="item.goods_img"
            class="imge"
            alt=""
          >
          <div class="text-Dev">
            {{item.goods_name}}
          </div>
          <div class="Hot">爆品推荐</div>
          <div class="money-Dev">
            ¥
            <span>{{item.active_price}}</span>
          </div>
          <span class="btn">立即抢购</span>
        </li>
      </ul>
    </div>
    <!-- 快乐2 -->
    <div class="happy">
      <ul>
        <li
          v-for="item in lister"
          :key="item.goods_id"
          @click="nav(item)"
        >
          <div class="back">
            <img
              class="one-hit"
              :src="item.goods_img"
              alt=""
            >
          </div>

          <div class="text-one"> {{item.goods_name}}</div>
          <div class="money-Hot">¥
            <span>{{item.active_price}}</span>
          </div>
        </li>
      </ul>
    </div>
    <!-- title2 -->
    <img
      src="../../assets/img/disney/title2@2x.png"
      class="images"
      alt=""
    >
    <!-- 童趣精选 -->
    <div class="item">
      <ul>
        <li
          v-for="item in atr"
          :key="item.goods_id"
          @click="nav(item)"
        >
          <div class="back">
            <img
              class="one-hit"
              :src="item.goods_img"
              alt=""
            >
          </div>

          <div class="text-one"> {{item.goods_name}}</div>
          <div class="money-Hot">¥ {{item.active_price}}</div>
          <div class="Go-hot">立即抢购</div>
        </li>
      </ul>
    </div>
    <div class="happy">
      <ul>
        <li
          v-for="item in atrdev"
          :key="item.goods_id"
          @click="nav(item)"
        >
          <div class="back">
            <img
              class="one-hit"
              :src="item.goods_img"
              alt=""
            >
          </div>

          <div class="text-one"> {{item.goods_name}}</div>
          <div class="money-Hot">¥
            <span>{{item.active_price}}</span>
          </div>
        </li>
      </ul>
    </div>
    <div
      class="moy"
      @click="ping"
    >更多推荐></div>
    <!-- 微信遮罩 -->
    <div
      @touchmove.prevent
      class="rigth"
      v-if="show"
    >
      <img
        src="../../assets/img/wei_20210307160153.png"
        alt=""
      >
    </div>
    <!-- 置顶 -->
    <div
      class="totop"
      id="totop"
      @click="backTop"
      v-show="btnFlag"
    >
      <!-- <i class="iconfont icon-zhiding"></i> -->
    </div>
  </div>
</template>

<script>
import bridge from '../../js/js1'
import { index, Coupondev } from '@/api/index'
import { share } from '../../js/wechat'
import { getSystem, openApp, getUrlQuery, parseKeyValue } from '../../js/js'
export default {
  // 组件名称
  name: '',
  // 局部注册的组件
  components: {},
  // 组件参数 接收来自父组件的数据
  props: {},
  // 组件状态值
  data () {
    return {
      list: [],
      lister: [],
      listdev: [],
      show: false,
      system: getSystem(),
      atr: [],
      atrdev: [],
      listerdev: [],
      share: true,
      scrollTop: 0,
      btnFlag: false,
      showTips: false,
    }
  },
  destroyed () {
    window.removeEventListener('scroll', this.scrollToTop);
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 生命周期钩子   注：没用到的钩子请自行删除
  /**
  * 组件实例创建完成，属性已绑定，但DOM还未生成，$ el属性还不存在
  */
  created () {
    this.create()
    // this.weixin()
  },
  /**
  * el 被新创建的 vm.el 替换，并挂载到实例上去之后调用该钩子。
  * 如果 root 实例挂载了一个文档内元素，当 mounted 被调用时 vm.el 也在文档内。
  */
  mounted () {
    window.addEventListener('scroll', this.scrollToTop)
    share({
      title: '媛福达app商城，迪士尼专场!',
      desc: '挚爱甄选 惊喜不停，童年好物分享，全场11.7元起！',
      imgUrl: 'https://download.yuanfuda933.com/h5/images/disney.png',
      shareUrl: 'https://download.yuanfuda933.com/h5/other2.html#/disney',
    })
  },
  // 组件方法
  methods: {
    ping () {
      if (this.system.wechat) {
        this.show = true
        return false
      } else {
        this.show = false
      }
      window.location.href = 'yfd://yfdmall:8080/homePage'
    },
    // 点击图片回到顶部方法，加计时器是为了过渡顺滑
    backTop () {
      const that = this
      let timer = setInterval(() => {
        let ispeed = Math.floor(-that.scrollTop / 5)
        document.documentElement.scrollTop = document.body.scrollTop = that.scrollTop + ispeed
        if (that.scrollTop === 0) {
          clearInterval(timer)
        }
      }, 16)
    },
    // 为了计算距离顶部的高度，当高度大于60显示回顶部图标，小于60则隐藏
    scrollToTop () {
      const that = this
      let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
      that.scrollTop = scrollTop
      // console.log(that.scrollTop);
      if (that.scrollTop > 800) {
        that.btnFlag = true
      } else {
        that.btnFlag = false
      }
    },
    async create () {
      try {
        const res = await index({
          id: 63
        })
        console.log(res.data.data.types);
        this.list = res.data.data.types[0].goods.slice(0, 2)
        this.lister = res.data.data.types[0].goods.slice(2, 10)

        this.atr = res.data.data.types[1].goods.slice(0, 2)
        console.log(this.atr);
        this.atrdev = res.data.data.types[1].goods.slice(2, 23)
      } catch (err) {
        console.log('错误');
      }
    },
    // 跳转下载
    nav (item) {
      if (this.system.wechat) {
        this.show = true
        return false
      } else {
        this.show = false
      }
      // console.log(item);
      if (this.system.android) {
        openApp({
          query: { spuId: item.goods_id }
        })
      }
      if (this.system.iOS) this.href('https://itunes.apple.com/cn/app/id1542709823?mt=8')

    },
    href (uri, blank = true) {
      const a = document.createElement('a')
      a.style.display = 'none'
      a.href = uri
      if (blank) a.setAttribute('target', '_blank')
      document.body.appendChild(a)
      a.click()
      setTimeout(t => {
        document.body.removeChild(a)
      }, 0)
    },
  }
}
</script>

<style scoped lang="less">
.body {
  overflow: hidden;
  min-width: 320px;
  max-width: 750px;
  width: 10rem;
  // height: 93.12rem;
  margin: 0 auto;
  line-height: 1.5;
  background: -webkit-linear-gradient(top, #b2e4ff, #5cbfff);
  font-family: Arial, Helvetica;
  .moy {
    width: 2.746667rem;
    height: 0.613333rem;
    margin: 0.266667rem auto;
    border-radius: 0.2rem;
    font-size: 0.373333rem;
    color: #ffffff;
    text-align: center;
    line-height: 0.61rem;
    border: 0.026667rem solid#FFFFFF;
    background: -webkit-linear-gradient(top, #b2e4ff, #5cbfff);
  }
  .totop {
    position: fixed;
    width: 1.2rem; /* 40/16 */
    height: 1.2rem;
    border-radius: 1.25rem /* 20/16 */;
    opacity: 0.8;
    background: url("../../assets/ding.png") no-repeat;
    background-size: contain;
    box-shadow: 0 1px 5px 0 #e0e0e0;
    right: 0.125rem; /* 18/16 */
    bottom: 3rem; /* 64/16 */
    z-index: 1100;
    -webkit-transition: opacity 0.5s;
    transition: opacity 0.5s;
  }
  .rigth {
    position: fixed;
    top: 0;
    z-index: 9999;
    width: 10rem;
    height: 30rem;
    background-color: #1e1e1e;
    opacity: 0.8;
  }
  .rigth img {
    width: 8rem;
    height: 4.4rem;
    float: right;
  }
  .text {
    width: 5.6rem;
    height: 0.533333rem;
    font-weight: 600;
    text-align: center;
    margin: 0 auto;
    font-size: 0.533333rem;
    color: #2e8de5;
  }
  .header {
    background: url("../../assets/img/disney/header.png") no-repeat;
    background-size: contain;
    width: 10rem;
    height: 10.213333rem;
  }
  // g购物卡
  .six {
    border-radius: 0.266667rem;
    width: 9.6rem;
    margin: 0.266667rem auto;
    height: 3.333333rem;
    background: -webkit-linear-gradient(top, #4ac3f9, #3398e9);
    ul {
      overflow: hidden;
      padding-top: 0.153333rem;
      li {
        margin-left: 0.13rem;
        width: 2.24rem;
        height: 2.96rem;
        float: left;
        .btn {
          width: 1.6rem;
          height: 0.56rem;
          font-size: 0.266667rem;
          color: #ffffff;
          margin: 2rem auto 0;
          text-align: center;
          border-radius: 0.233333rem;
          line-height: 0.56rem;
          background: -webkit-linear-gradient(top, #2e8de5, #5cbfff);
          animation: mymove 2s infinite;
          -webkit-animation: mymove 2s infinite; /*Safari and Chrome*/
          animation-direction: alternate; /*轮流反向播放动画。*/
          animation-timing-function: ease-in-out; /*动画的速度曲线*/
          /* Safari 和 Chrome */
          -webkit-animation: mymove 2s infinite;
          -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
        }
      }
      li:nth-child(1) {
        background: url("../../assets/img/disney/110@2x.png") no-repeat;
        background-size: contain;
      }
      li:nth-child(2) {
        background: url("../../assets/img/disney/230@2x.png") no-repeat;
        background-size: contain;
      }
      li:nth-child(3) {
        background: url("../../assets/img/disney/590@2x.png") no-repeat;
        background-size: contain;
      }
      li:nth-child(4) {
        background: url("../../assets/img/disney/1000@2x.png") no-repeat;
        background-size: contain;
      }
    }
  }
  .images {
    width: 10rem;
    height: 2.906667rem;
  }
  .goods {
    width: 9.493333rem;
    margin: 0 auto;
    overflow: hidden;
    ul li {
      position: relative;
      overflow: hidden;
      width: 9.493333rem;
      height: 3.866667rem;
      background: #ffffff;
      border-radius: 0.266667rem;
      margin-bottom: 0.266667rem;
      .Hot {
        position: absolute;
        top: 50%;
        right: 41%;
        width: 1.6rem;
        height: 0.426667rem;
        font-size: 0.32rem;
        text-align: center;
        line-height: 0.42rem;
        border-radius: 0.133333rem;
        color: #ff9797;
        border: 0.026667rem solid #ff9797;
      }
      .imge {
        width: 3.386667rem;
        height: 3.386667rem;
        background: #dddddd;
        margin-top: 0.266667rem;
        margin-left: 0.266667rem;
        border-radius: 0.166667rem;
      }
      .text-Dev {
        float: right;
        margin-top: 0.32rem;
        margin-right: 1.2rem;
        color: #000000;
        width: 4.32rem;
        height: 1.76rem;
        font-size: 0.426667rem;
        font-weight: 600;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }
      .money-Dev {
        position: absolute;
        top: 73%;
        left: 41%;
        width: 2.4rem;
        height: 0.8rem;
        font-size: 0.426667rem;
        // font-weight: 600;
        color: #ff3f53;
        span {
          font-size: 0.533333rem;
        }
      }
      .btn {
        position: absolute;
        right: 8%;
        top: 75%;
        width: 2.426667rem;
        height: 0.693333rem;
        font-size: 0.426667rem;
        text-align: center;
        line-height: 0.693rem;
        color: #ffffff;
        background: -webkit-linear-gradient(top, #b2e4ff, #5cbfff);
        border-radius: 0.08rem;
        animation: mymove 2s infinite;
        -webkit-animation: mymove 2s infinite; /*Safari and Chrome*/
        animation-direction: alternate; /*轮流反向播放动画。*/
        animation-timing-function: ease-in-out; /*动画的速度曲线*/
        /* Safari 和 Chrome */
        -webkit-animation: mymove 2s infinite;
        -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
      }
      .box-Dev {
        float: right;
        color: #960b0b;
        width: 2.033333rem;
        height: 0.6rem;
        font-size: 0.32rem;
        text-align: center;
        line-height: 0.603333rem;
        border-radius: 0.266667rem;
        margin-top: -0.64rem;
        margin-right: 0.173333rem;
        background: -webkit-linear-gradient(top, #f8dec5, #ddb384);
      }
    }
  }
  .happy {
    width: 9.493333rem;
    margin: 0 auto;
    overflow: hidden;
    ul li {
      float: left;
      width: 2.933333rem;
      height: 4.826667rem;
      overflow: hidden;
      background: #ffffff;
      margin-left: 0.173333rem;
      margin-bottom: 0.266667rem;
      border-radius: 0.266667rem;
      .back {
        overflow: hidden;
        width: 100%;
        height: 3.093333rem;
        background-color: #f8f8f7;
        border-radius: 0.266667rem;
        .one-hit {
          display: block;
          margin: 0.296667rem auto;
          width: 2.3rem;
          height: 2.3rem;
        }
      }
      .text-one {
        font-size: 0.32rem;
        color: #333333;
        width: 2.733333rem;
        margin: 0 auto;
        height: 0.906667rem;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }
      .money-Hot {
        font-weight: 600;
        margin-top: 0.206667rem;
        margin-left: 0.136667rem;
        font-size: 0.266667rem;
        color: #f83514;
        span {
          font-size: 0.373333rem;
        }
      }
    }
  }
  .item {
    overflow: hidden;
    width: 10rem;
    ul li {
      float: left;
      position: relative;
      width: 4.613333rem;
      margin-left: 0.2553333rem;
      margin-bottom: 0.16rem;
      height: 7.226667rem;
      border-radius: 0.266667rem;
      background-color: #ffffff;
      .back {
        width: 100%;
        height: 4.56rem;
        background-color: #f8f8f7;
        border-radius: 0.266667rem;
        .one-hit {
          width: 4.053333rem;
          height: 3.693333rem;
          margin-top: 0.266667rem;
          margin-left: 0.32rem;
        }
      }
      .text-one {
        width: 4.04rem;
        height: 1.093333rem;
        font-size: 0.373333rem;
        color: #000000;
        margin: 0 auto;
        // font-weight: 600;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }
      .money-Hot {
        width: 1.733333rem;
        height: 0.533333rem;
        font-size: 0.426667rem;
        margin-left: 0.32rem;
        margin-top: 0.08rem;
        font-weight: 600;
        color: red;
      }
      .Go-hot {
        // position: absolute;
        // right: 10%;
        // bottom: 3%;
        width: 4.106667rem;
        height: 0.72rem;
        margin: 0 auto;
        font-size: 0.426667rem;
        text-align: center;
        line-height: 0.72rem;
        color: #ffffff;
        border-radius: 0.1rem;
        // border: 0.013333rem solid #6d240b;
        background: #58afe8;
      }
    }
  }
  @keyframes mymove {
    0% {
      transform: scale(1); /*开始为原始大小*/
    }
    25% {
      transform: scale(1.1); /*放大1.1倍*/
    }
    50% {
      transform: scale(1);
    }
    75% {
      transform: scale(1.1);
    }
  }
  @-webkit-keyframes mymove /*Safari and Chrome*/ {
    0% {
      transform: scale(1); /*开始为原始大小*/
    }
    25% {
      transform: scale(1.1); /*放大1.1倍*/
    }
    50% {
      transform: scale(1);
    }
    75% {
      transform: scale(1.1);
    }
  }
}
</style>
